< previous page page_96 next page >

Page 96
whereas this will use the second implementation:
Dim theCheckingAccount As New CheckingAccount
Dim theBankAccount As BankAccount
Set theBankAccount = theCheckingAccount
theBankAccount.deposit
Thus, invoking theBankAccount.deposit with an implementation by SavingsAccount, an argAmount value of 100.00, and a msgl_Balance of 0.00 would result in a new value for msgl_Balance of 100.00. However, if you invoke theBankAccount.deposit with an implementation by CheckingAccount with the same argAmount value and a fee of 10.00, msgl_Balance would equal 90.00. The polymorphic effect is made manifest by the difference of 10.00 in the two different implementations of BankAccount.
Understanding Object Interface Communication
Object-to-object communication occurs through the interfaces of each object. In its most essential definition, an interface is the set of public methods that a class implements. For Visual Basic, a class interface also includes public properties. Implementing an interface means that an object supplies some expected behavior to its client. That expected behavior is made manifest in the form of some returned message, such as a value or object. In the course of supplying this expected behavior, an object can delegate some of its duties to other objects.
When a client object invokes the public method of another, is that method invocation an operation, or is the method itself an operation? There's much speculation on this issue in the object technology community. Nonetheless, an operation is more abstract than a method invocation and should not necessarily be seen as synonymous with the method itself. If a public method encapsulates all the code necessary to provide the expected behavior without the aid of private methods, the event of invoking that method triggers an operation. That is, the operation is a series of instructions. If the event of invoking the method results in other private methods in the object being invoked or even methods of other objects, the sum of the series of instructions implemented by all these methods is an operation.

 
< previous page page_96 next page >

If you like this book, buy it!